Completed
Push — master ( 91b2b7...b3d439 )
by Johan
01:09
created

gulp.task(ꞌjsdelivrꞌ)   B

Complexity

Conditions 1
Paths 2

Size

Total Lines 24

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
c 1
b 0
f 0
nc 2
nop 1
dl 0
loc 24
rs 8.9713

1 Function

Rating   Name   Duplication   Size   Complexity  
A ��) 0 18 3
1
/*eslint no-console: 0 */
2
3
var gulp = require('gulp');
4
var request = require('request');
5
var fs = require('fs');
6
7
gulp.task('jsdelivr', function(callback){
8
	console.log("Making request...");
0 ignored issues
show
Debugging Code introduced by
console.log looks like debug code. Are you sure you do not want to remove it?
Loading history...
9
	request({
10
		url: "https://api.jsdelivr.com/v1/jsdelivr/libraries?name=jsbarcode",
11
		json: true
12
	}, function (error, response, body) {
13
		if (!error && response.statusCode === 200) {
14
			var readme = fs.readFileSync('README.md', "utf-8");
15
			var version = body[0].lastversion;
16
17
			readme = readme.replace(/https:\/\/cdn\.jsdelivr\.net\/jsbarcode\/[0-9]+\.[0-9]+\.[0-9]+\//g,
18
				"https://cdn.jsdelivr.net/jsbarcode/" + version + "/");
19
20
			fs.writeFileSync('README.md', readme, 'utf8');
21
22
			console.log("New version: " + version);
0 ignored issues
show
Debugging Code introduced by
console.log looks like debug code. Are you sure you do not want to remove it?
Loading history...
23
			callback();
24
		}
25
		else{
26
			console.error("Failed to make jsdelivr api request");
27
			callback();
28
		}
29
	});
30
});
31